package com.njym.java.security.app.util; /**
 * @Title: CharUtil
 * @ProjectName family-benefit
 * @Description: TODO
 * @author 71705
 * @date 2019/11/2616:13
 */

import java.util.Random;

/**
 * @program: family-benefit
 *
 * @description:
 *
 * @author: lijie
 *
 * @create: 2019-11-26 16:13
 **/
public class CharUtil {
    public static String getRandomString(Integer num) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < num; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }

    public static String getRandomNum(Integer num) {
        String base = "0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < num; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }

}
